//Accepted
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;

int i, j, x, y, sum, a, n, m, t;
bool p[30000];
int main(){
	//freopen("in.txt","r",stdin);
	scanf("%d", &t);
	
	while(t--){
		queue<int> q;
		scanf("%d%d", &n, &m);
		vector<int> v[n];
		for(i=0;i<m;++i){
			scanf("%d%d", &x, &y);
			--x;--y;
			v[x].push_back(y);
			v[y].push_back(x);
		}
		memset(p,1,sizeof(p));
		sum=0;
		for(i=0;i<n;++i){
			if(p[i]){
				
				q.push(i);
				p[i]=0;
				a=1;
				
				while(!q.empty()){
					x=q.front();q.pop();
					
					for(j=0;j<v[x].size();++j){
						y=v[x][j];
						
						if(p[y]){
							q.push(y);
							p[y]=0;
							++a;
						}
					}
					
				}
				if(a>sum)sum=a;
				
			}
		}
		printf("%d\n", sum);
		
	}
	return 0;
}
